<%@ page errorPage="/jsp/exceptionHandler.jsp"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Date"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.metagurukul.metaspace.models.beans.UserWorkDetail"%>
<%@page import="com.metagurukul.metaspace.service.UserService"%>
<%@page
	import="com.metagurukul.metaspace.models.beans.UserPersonalDetail"%>
<%
	if (session.getAttribute("user") == null)
		response.sendRedirect("../index.jsp");
%>

<html>
<title>Home Page</title>
<head>
<script type="text/javascript" src="../resources/js/jquery.js"></script>
<SCRIPT type="text/javascript">
	$(document).ready(function() {
		if (window != top)
			top.location.href = location.href;
	});

	window.history.forward();
	function noBack() {
		window.history.forward();
	}
	function search() {
		window.open("/jsp/search.jsp?txt="
				+ document.getElementById("searchTxt").value, "content");
	}
</SCRIPT>
<link rel="stylesheet" type="text/css"
	href="../resources/css/masterLayoutStyle.css" />
<link rel="stylesheet" href="../resources/css/style.css" />



</head>

<body onload="noBack();">
	<%
		int userId = -1;
		if (request.getSession().getAttribute("id") != null) {
			userId = (Integer) request.getSession().getAttribute("id");
		}
		UserPersonalDetail userPersonalDetail = UserService
				.getUserPersonalDetail(userId);
		String userName = "Please update Your Name";
		String profilePic = "0male.jpg";
		if (userPersonalDetail == null) {
			response.sendRedirect("/jsp/registrationDetail.jsp");
		} else {
			userName = userPersonalDetail.getName();
			if (userPersonalDetail.getProfilePicPath() != null) {
				profilePic = userPersonalDetail.getProfilePicPath();
			} else {
				profilePic = "0male.jpg";
			}
		}
	%>
	<div id="header">
		<table style="border: 0; width: 100%; height: 100%">
			<tr>
				<td width="25%" align="center"><a href="/jsp/home.jsp"><img
						src="../resources/images/logo.jpg" /> </a>
				</td>
				<td width="35%" align="center"><input type="text"
					style="font-size: 19px; margin-top: 1px" id="searchTxt" size=23 /><input
					type="button" id="invite" class="btn btn-inverse" value="Search"
					onclick="search()" /></td>
				<td width="40%">
					<ul id="mainMenu" class="topmenu">
						<li class="topmenu"><a href="/jsp/home.jsp"
							style="height: 20px; line-height: 20px;"><img
								src="../resources/images/home.png" alt="" />Home</a></li>
						<li class="topmenu"><a href="#"
							style="height: 20px; line-height: 20px;"><span><img
									src="../resources/images/samples.png" alt="" />Settings</span> </a>
							<ul>
								<li><a href="/jsp/profile.jsp" target="content">My
										Profile</a></li>
								<li><a href="/jsp/changePassword.jsp">Change Password</a></li>
								<li><a href="/jsp/personalDetails.jsp" target="content">Edit
										Personal Information</a></li>
								<li><a href="/jsp/workDetails.jsp" target="content">Edit
										Work Details</a></li>
							</ul></li>
						<li class="topmenu"><a href="../Logout"
							style="height: 20px; line-height: 20px;">Sign Out</a></li>
					</ul></td>
			</tr>
		</table>
	</div>

	<div id="container">
		<center>
			<div id='leftContainer' class="bigContainer" style="float: left">
				<div id="verticalMenuContainer" class="smallContainers big">
					<ul>
						<li class="menuHead"><center>
								<a href="/jsp/profile.jsp" target="content"> <%
 	out.write(userName);
 %> </a>
							</center></li>
						<li><a href="#"><img
								src="../resources/images/users/<%=profilePic%>" width="160px"
								height="120px" border="1px" style="border-color: GREY"
								alt="<%=profilePic%>" /> </a></li>
						<li><a href="/jsp/changePicture.jsp" target="content">Edit
								Picture </a>
					</ul>
				</div>
				<%
					UserWorkDetail userWorkDetail = UserService
							.getUserWorkDetail(userId);
					boolean flag = false;
					if (userWorkDetail == null) {
						flag = true;
					}
				%>
				<div id="verticalMenuContainer" class="smallContainers medium">
					<ul style="text-align: left;">
						<li class="menuHead">Job Details</li>
						<li><b>Department : </b> <span style="color: gray"> <%
 	if (!flag) {
 		out.println(userWorkDetail.getDepartmentName());
 	}
 %> </span>
						</li>
						<li><b>Project : </b><span style="color: gray"> <%
 	if (!flag && userWorkDetail.getUserProjectList().size() > 0) {
 		out.println(userWorkDetail.getUserProjectList().get(0)
 				.getProjectName());
 	}
 %> </span>
						</li>
						<li><b>Role : </b><span style="color: gray"> <%
 	if (!flag) {
 		out.println(userWorkDetail.getRoleName());
 	}
 %> </span>
						</li>
					</ul>
				</div>
			</div>
			<div id='centerBody' align="left">
				<iframe src="/jsp/status.jsp" name="content" id="content"
					style="border: 0; width: 100%; overflow: auto; min-height: 450px;"></iframe>
			</div>
		</center>
		<div id="rightContainer" class="bigContainer" style="float: right">
			<div id="verticalMenuContainer" class="smallContainers big">
				<ul>
					<li class="menuHead">Team Members</li>
				</ul>
				List of Team Members will be displayed here as an optional feature.
			</div>
			<div id="verticalMenuContainer" class="smallContainers big">
				<ul>
					<li class="menuHead">Birthday Notifications</li>
				</ul>
				<table cellspacing=10px>
				<% List<UserPersonalDetail> userPersonalDetailList = UserService.getUserPersonalDetailList();
					for(int i=0; i < userPersonalDetailList.size(); i++) {
						Date currentDate = new Date();
						if((userPersonalDetailList.get(i).getDate().getDate() == currentDate.getDate()) & (userPersonalDetailList.get(i).getDate().getMonth() == currentDate.getMonth())) {
							if(userPersonalDetailList.get(i).getProfilePicPath()!=null) {
								profilePic = userPersonalDetailList.get(i).getProfilePicPath();
							} else {
								profilePic = "0male.jpg";
							} %>
							<tr><td rowspan = "2"><a  target="content" href="/jsp/profile1.jsp?id=<%=userPersonalDetailList.get(i).getUserId() %>"><img src="../resources/images/users/<%=profilePic%>" width="50px" height="50px" alt="<%=userPersonalDetailList.get(i).getName()%>" /></a></td><td colspan=2><a  target="content" href="/jsp/profile1.jsp?id=<%=userPersonalDetailList.get(i).getUserId() %>"><%=userPersonalDetailList.get(i).getName() %></a></td></tr>
							<tr><td></td><td></td></tr>
							<%							
						}
					}				
				%>
				
				</table>
			</div>
		</div>
	</div>
	<jsp:include page="/jsp/footer.jsp"></jsp:include>
</body>
</html>

